When `ungrabFocus()` is called after hiding a notification, the previous
focus actor might have already been destroyed and trying to focus it
will trigger a gjs error.
Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/work_items/9190
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4197>
this._prevKeyFocusActor = global.stage.get_key_focus();
+ this._prevKeyFocusActor?.connectObject('destroy', () => {
+ this._prevKeyFocusActor = null;
+ }, this);
+
global.stage.connectObject('notify::key-focus',
this._focusActorChanged.bind(this), this);
if (!this._focused)
return false;
+ this._prevKeyFocusActor?.disconnectObject(this);
+
global.stage.disconnectObject(this);
this._focused = false;